package com.tiandang.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import tiandang.core.response.CommonReturnType;
import tiandang.core.service.ManagerApplyService;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/api/managerApply")
public class ManagerApplyController {

  @Autowired
  private ManagerApplyService managerApplyService;

  @GetMapping("/getList")
  public CommonReturnType getList(@RequestParam(value = "currentPage", defaultValue = "1") Integer currentPage,
                                  @RequestParam(value = "limit", defaultValue = "10") Integer limit) {

    return CommonReturnType.success(managerApplyService.getList(currentPage, limit));
  }

  @PostMapping("/delete")
  public Object delete(Integer id) {
    managerApplyService.delete(id);
    return CommonReturnType.success();
  }

  @GetMapping("/getDetail")
  public Object getDetail(Integer id) {
    Map<String, Object> resultMap = new HashMap<>();
    resultMap.put("managerApply", managerApplyService.getManagerApplyById(id));
    return CommonReturnType.success(resultMap);
  }


}
